package com.cxf.windex.entity;

import com.cxf.windex.enums.ArticleTypeEnum;
import lombok.*;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;

/**
 * 文章信息
 * @author chenxf
 */
@Table(name = "js_contents")
@Builder(toBuilder = true)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@NoArgsConstructor
@Getter
@Setter
public class JsContents {
    /**
     * ID
     */
    @Id
    private String id;

    /**
     * 创建时间
     */
    @Column(name = "crt_time")
    private Date crtTime;

    /**
     * 创建用户id
     */
    @Column(name = "crt_user")
    private String crtUser;

    /**
     * 创建用户姓名
     */
    @Column(name = "crt_name")
    private String crtName;

    /**
     * 创建用户IP
     */
    @Column(name = "crt_host")
    private String crtHost;

    /**
     * 标题
     */
    private String title;

    /**
     * 摘要
     */
    private String intro;

    /**
     * 文章图片
     */
    private String image;

    /**
     * 文章类型
     */
    private String type;

    /**
     * 状态
     */
    private String status;

    /**
     * 文章内容
     */
    private String content;

    /**
     * 类型 1商家 2村长
     */
    @Column(name = "ranges")
    private String range;

    /**
     * 排序值
     */
    @Column(name = "order_no")
    private String orderNo;

    @Transient
    private String typeDesc;

    public void setType(String type){
        this.type=type;
        this.typeDesc= ArticleTypeEnum.getIdType(type).getDesc();
    }
}
